/*
 * This program is free software: you can redistribute it and/or modify it under the terms of the 
 * GNU Affero General Public License as published by the Free Software Foundation, either version 3 
 * of the License, or (at your option) any later version.
 * 
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3, 
 * the Appropriate Legal Notices must display the following words on all interactive user interfaces: 
 * "Copyright (C) 2005-2011 SplendidCRM Software, Inc. All rights reserved."
 */

var Crm =
{
	Config: 
	{
		enable_team_management: function()
		{
			var bgPage = chrome.extension.getBackgroundPage();
			return Sql.ToBoolean(bgPage.SplendidCache.Config('enable_team_management'));
		}
		, require_team_management: function()
		{
			var bgPage = chrome.extension.getBackgroundPage();
			return Sql.ToBoolean(bgPage.SplendidCache.Config('require_team_management'));
		}
		, enable_dynamic_teams: function()
		{
			var bgPage = chrome.extension.getBackgroundPage();
			return Sql.ToBoolean(bgPage.SplendidCache.Config('enable_dynamic_teams'));
		}
		, require_user_assignment: function()
		{
			var bgPage = chrome.extension.getBackgroundPage();
			return Sql.ToBoolean(bgPage.SplendidCache.Config('require_user_assignment'));
		}
	}
	, Modules:
	{
		TableName: function(sMODULE)
		{
			var bgPage = chrome.extension.getBackgroundPage();
			return bgPage.SplendidCache.Module(sMODULE).TABLE_NAME;
		}
		, ExchangeFolders: function(sMODULE)
		{
			var bgPage = chrome.extension.getBackgroundPage();
			var oModule = bgPage.SplendidCache.Module(sMODULE);
			return Sql.ToBoolean(oModule.EXCHANGE_SYNC) && Sql.ToBoolean(oModule.EXCHANGE_FOLDERS);
		}
	}
	, Teams:
	{
		Name: function(sID)
		{
			var bgPage = chrome.extension.getBackgroundPage();
			var rowTeam = bgPage.SplendidCache.Team(sID);
			if ( rowTeam !== undefined && rowTeam != null )
				return rowTeam.NAME;
			else
				return '';
		}
	}
};

var Security =
{
	USER_ID: function()
	{
		var bgPage = chrome.extension.getBackgroundPage();
		return bgPage.SplendidCache.UserID();
	}
	, USER_NAME: function()
	{
		var bgPage = chrome.extension.getBackgroundPage();
		return bgPage.SplendidCache.UserName();
	}
	, FULL_NAME: function()
	{
		var bgPage = chrome.extension.getBackgroundPage();
		return bgPage.SplendidCache.FullName();
	}
	, USER_LANG: function()
	{
		var bgPage = chrome.extension.getBackgroundPage();
		return bgPage.SplendidCache.UserLang();
	}
	, USER_DATE_FORMAT: function()
	{
		var bgPage = chrome.extension.getBackgroundPage();
		return bgPage.SplendidCache.UserDateFormat();
	}
	, USER_TIME_FORMAT: function()
	{
		var bgPage = chrome.extension.getBackgroundPage();
		return bgPage.SplendidCache.UserTimeFormat();
	}
	, TEAM_ID: function()
	{
		var bgPage = chrome.extension.getBackgroundPage();
		return bgPage.SplendidCache.TeamID();
	}
	, TEAM_NAME: function()
	{
		var bgPage = chrome.extension.getBackgroundPage();
		return bgPage.SplendidCache.TeamName();
	}
};


